from django.db import models
from django.utils import timezone  #!
import datetime#!
#
# # Create your models here.
# class Small_Yaml(models.Model):
#     def __str__(self):
#         return self.description_get
# class Informatin(models.Model):
#     small_yaml=models.OneToOneField('generate_yaml.Small_Yaml',on_delete=models.CASCADE,)
#     model=models.CharField(max_length=300)
#     factory=models.CharField(max_length=120)
#     def __str__(self):
#         return self.model,self.factory
#
# class Description(models.Model):
#     small_yaml=models.OneToOneField('generate_yaml.Small_Yaml',on_delete=models.CASCADE,)
#     time=models.DateTimeField(verbose_name="生成时间",auto_now_add=True,auto_created=True)
#     author=models.CharField(verbose_name="作者",max_length=50)
#     history=models.CharField(max_length=500)
#     name=models.CharField(verbose_name="用例名",max_length=500)
#     purpose = models.CharField(verbose_name="意图",max_length=500)
#     def __str__(self):              # __unicode__ on Python 2
#         return self.id
#
#
# class Bundle(models.Model):
#     # cash_flag=models.BooleanField() #不让cash在admin中显示
#     small_yaml=models.ForeignKey('generate_yaml.Small_Yaml',on_delete=models.CASCADE,)
#     setup=models.CharField(verbose_name="运行前命令执行",max_length=500)
#     teraoff=models.CharField(verbose_name="运行后命令执行",max_length=500)
#     def __str__(self):              # __unicode__ on Python 2
#         return self.id
#
# #公有继承
# class Common_info(models.Model):
#     FilePath_all=models.CharField(verbose_name="样本库路径",max_length=20)
#     value_all=models.IntegerField(verbose_name="面额")
#     currency_all=models.CharField(verbose_name="币种",max_length=20)
#     version_all=models.IntegerField(verbose_name="版本")
#     sn_all=models.CharField(verbose_name="冠字号",max_length=100)
#     error_code_all=models.CharField(verbose_name="错误值",max_length=20)
#     after_break_all=models.BooleanField(verbose_name="刹车后")
#     def __str__(self):              # __unicode__ on Python 2
#         return self.id
#     class Meta:
#         abstract=True  #该表不能被实例化 只能被继承
# #FilePathField  用户需要输入的
# class Cash_Locate(Common_info):
#     #主表名字.cash_now.all() relate_name！！！
#     bundle_all=models.OneToOneField('generate_yaml.Bundle',on_delete=models.CASCADE,related_name="cash_zero")
#     # FilePath_all=models.CharField(verbose_name="样本库路径",max_length=20)
#     # value_all=models.IntegerField(verbose_name="面额")
#     # currency_all=models.CharField(verbose_name="币种",max_length=20)
#     # version_all=models.IntegerField(verbose_name="版本")
#     # sn_all=models.CharField(verbose_name="冠字号",max_length=100)
#     # error_code_all=models.CharField(verbose_name="错误值",max_length=20)
#     # after_break_all=models.BooleanField(verbose_name="刹车后")
#     def __str__(self):              # __unicode__ on Python 2
#         return self.id
# #经过程序后需要保存的
# class Cash(Common_info):
#     #！！！！！！！！！！！！！！！！！！！limit_choice_to?
#     #外键多对一引用 模拟SQL语言中的ON DELETE CASCADE约束，将定义有外键的模型对象同时删除！
#     bundle_test=models.ForeignKey('generate_yaml.Bundle', on_delete=models.CASCADE,)   #外键显示
#     # 被传到`MEDIA_ROOT/uploads/年月日`目录，增加了一个时间划分 media_root在setting中设置
#     ADC1FileName=models.FileField(verbose_name='ADC1文件位置',upload_to='uploads/%Y/%m/%d/',help_text="别填")
#     topCISFileName=models.FileField(verbose_name='TopCIS文件位置',upload_to='uploads/%Y/%m/%d/')
#     ADC0FileName=models.FileField(verbose_name='ADC0文件位置',upload_to='uploads/%Y/%m/%d/')
#     bottomCISFileName=models.FileField(verbose_name='bottomCIS文件位置',upload_to='uploads/%Y/%m/%d/')
#     # value_test=models.IntegerField(verbose_name="面额")
#     # currency_test=models.CharField(verbose_name="币种",max_length=20)
#     # version_test=models.IntegerField(verbose_name="版本")
#     # sn_test=models.CharField(verbose_name="冠字号",max_length=100)
#     # error_code_test=models.CharField(verbose_name="错误值",ax_length=20)
#     # after_break_test=models.BooleanField(verbose_name="刹车后")
#     def __str__(self):              # __unicode__ on Python 2
#         return self.id
#     class Meta:
#         db_table='cash_test'
#         verbose_name="一张钞票"
#         #四个不相同才能够创建
#         unique_together=(('ADC1FileName','topCISFileName','ADC0FileName','bottomCISFileName'),)
#
#
# #回调函数返回文件存放路径
#
# import re,time
# def user_directory_path(instance,filename):
#     file_author_pattern=re.compile(r'(_[0-9]{2}_[0-9]{2}_[0-9]{2}_)(.*?)_')
#     file_author_group=file_author_pattern.search(filename)
#     file_author=file_author_group.group(2)
#     format_time = time.strftime("%Y-%m-%d_%H_%M_%S")
#     path='Upload_yaml/{0}/{1}/'.format(file_author,format_time)
#     return path
#
# class yaml_file(models.Model):
#     upload=models.FileField(upload_to=user_directory_path)










